package com.taocore.top.title.service;

import com.taocore.top.title.domain.DiagnoseResult;

public class AttachmentsChecker implements TitleChecker{

	private static final String[] words = {"赠", "送", "带", "配"};
	private static final String[] excludes = {"皮带", "表带", "吊带", "丝带", "鞋带", "系带", "无带", "吊袜带"}; 
	
	@Override
	public DiagnoseResult check(String title) {
		
		for (String w : words)
		{
			if (title.contains(w))
			{
				if (ignore(title, w))
				{
					continue;
				}
				DiagnoseResult result = new DiagnoseResult();
				result.setMsg("标题出现赠送或者附带关系会影响得分。如赠xx、送 xx、 带xx、配xx。");
				return result;
			}
		}
		return null;
	}

	private boolean ignore(String title, String w)
	{
		if("带".equals(w))
		{
			for (String ignore : excludes)
			{
				if (title.contains(ignore))
				{
					return true;
				}
			}
		}
		return false;
	}
}
